package main;

import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;
import java.util.Comparator;




public final class MiniJavaTest {

	private MiniJavaTest() {
	}

	public static void main(String[] args) {
		run();
	}

	public static void run() {
		//Obtém os arquivos com extensão ".java" da pasta "test"
		File testDirectory = new File("test");
		File[] testFiles = testDirectory.listFiles(new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				return pathname.getName().endsWith(".java");
			}
		});

		//Ordena os arquivos por nome:
		Arrays.sort(testFiles, new Comparator<File>() {
			@Override
			public int compare(File o1, File o2) {
				return o1.getName().compareTo(o2.getName());
			}
		});

		try {
			for (File file : testFiles) {
				MiniJavaCompiler.main(new String[] { file.getAbsolutePath() });
			}
		} catch (Exception e) {
			System.out.println("TEST FAILED!");
			e.printStackTrace();
		}
	}
}
